﻿package code {
	
	public class Polygon extends BaseShape {
		// creates a n-sided polygon
		public function Polygon(radius:Number, sides:Number, color:uint, thickness:Number, hollow:Boolean, angle:Number) {
			super(radius, sides, color, thickness, hollow, angle)
			this.angle = angle;
			init();

		}
		
		private function init(){
			makeVertices();
			rotateVertices();
			renderVertices();
		}
		
				
		// calculate and store polygon vertices:
		override public function makeVertices():void {
			var centerX = 0;
			var centerY = 0
			
			// complete me by filling in vertices array with polygon vertices that you calculate procedurally
			var theta = (2 * Math.PI) / sides;  // gets the base value of theta
			
			for(var i:int  = 0; i < sides; i++)  // number of vertices is equal to the number of sides
			{
				var xPos:Number = (radius * Math.cos(i * theta)) + centerX;  // gets the position around the radius each vertex will be and translates it by the center position
				var yPos:Number = (radius * Math.sin(i * theta)) + centerY;
				var tempVert:Vertex = new Vertex(xPos, yPos);  // sets up a tempVertex to add to the vertices array
				vertices.push(tempVert);
				
			}
			
		}

	}
	
}
